package itemlog

import (
	"context"
	"xr-game-server/core/constants/common"
	"xr-game-server/core/httpserver"
	"xr-game-server/dao/itemlogdao"
	"xr-game-server/dto/itemlogdto"
	"xr-game-server/gamecfg"
)

func Page(context context.Context, req *itemlogdto.GetItemLogReq) (res *httpserver.CMSQueryResp, er error) {
	total, data := itemlogdao.Page(req)
	pageData := make([]*itemlogdto.ItemLogDto, common.Zero)
	for _, val := range data {
		pageData = append(pageData, itemlogdto.NewItemLogDto(val, gamecfg.GetItemSourceById(val.SourceId), gamecfg.GetItemById(val.ItemId)))
	}
	return httpserver.NewCMSQueryResp(total, pageData), nil
}
